<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script src="js/axios-0.18.0.js"></script>
</head>
<body>

</body>
<!--判断当前的登陆状态，如果是登录，跳转到main.html页面，如果未登录，跳转到login.html-->

<script>

  //获取浏览器保存的token信息
  let token = localStorage.getItem("token");
  //string-->boolean： 当字符串的值不为null，并且长度不为0，转换成true，否则为false
  if (token){
    axios({
      //请求资源路径
      url:"http://localhost:8081/user/isLogin",
      //请求方式
      method:"get",
      //请求头数据
      headers:{
        token:token
      }
    }).then(resp=>{
      let result = resp.data;
      if (result.code == 10000){
        //登录了--> main.html
        location.href = "pages/main.html"
      }else{
        //认证token不合法或者过期--> login.html
        location.href = "login.html"
      }
    });
  }else{
    //没登陆--->login.html
    location.href = "login.html"
  }

</script>
</html>